#define  _CRT_SECURE_NO_WARNINGS
#include "myhash.h"


template<class k,class v,class hash =hashfunc<k>>
class unordered_map
{
public:
	typedef hashnode<pair<k,v>> node;
	struct mapkeyoft
	{
		k operator()(const pair<k,v>& kv)
		{
			return kv.first;
		}
	};
	typedef typename hashtable<const k, pair<const k, v>, hash, mapkeyoft>::Iterator iterator;
	typedef typename hashtable<const k, pair<const k, v>, hash, mapkeyoft>::const_Iterator const_iterator;
	node* find(const k& key)
	{
		return _ht.find(key);
	}
	bool insert(const pair<const k,v>& kv)
	{
		return _ht.insert(kv).second;
	}
	bool erase(const k& key)
	{
		return _ht.erase(key);
	}
	v& operator[](const k& key)
	{
		pair<iterator, bool> ret = _ht.insert({ key,v() });
		return ret.first->second;
	}
	iterator begin()
	{
		return _ht.begin();
	}
	iterator end()
	{
		return _ht.end();
	}
	const_iterator begin() const 
	{
		return _ht.begin();
	}
	const_iterator end() const
	{
		return _ht.end();
	}
private:
	hashtable<const k, pair<const k,v>, hash, mapkeyoft> _ht;
};

